package com.devil.mcp.tools;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.devil.mcp.entity.ArticleInfo;
import com.devil.mcp.service.ArticleInfoService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Devil
 * @version 1.0
 * @description 文章信息工具
 * @date 2025/4/11 21:38
 */
@Service
public class ArticleInfoTools {
    @Autowired
    private ArticleInfoService articleInfoService;

    @Tool(description = "获取文章信息")
    String getArticleInfo(@ToolParam(description = "标题") String title) {
        List<ArticleInfo> articleInfoList = articleInfoService.list(Wrappers.<ArticleInfo>query().lambda().like(ArticleInfo::getTitle, title));
        return JSONUtil.toJsonStr(articleInfoList);
    }
}
